<%@ page language = "java" import = "java.util.*" %>
<%@ page import = "edu.colorado.karl.manctrl.ManualControl" %>
<%@ include file = "header.jspf" %>

<link rel="Stylesheet" type="text/css" media="Screen" charset="utf-8" href="css/common.css"/>

<h1>Updating Setpoints...</h1>

<%

ManualControl mc = ManualControl.getManualControl();
boolean update = true;

try
{
  int roomTemp = Integer.parseInt(request.getParameter("roomTemp"));
  int roomRange = Integer.parseInt(request.getParameter("roomRange"));

  if(roomRange < 1 || roomRange > 10)
  {
    update = false;

    %>

    <br>Error, range must be 1 - 10.
    <br><a link="manual_control.jsp">Return to manual control page</a>

    <%
  }

  if(roomTemp < 50 || roomTemp > 100)
  {
    update = false;

    %>

    <br>Error, room temperature must be 50-100.
    <br><a link="manual_control.jsp">Return to manual control page</a>    

    <%    
  }

  if(update)
  {
    mc.updateRoomSettings(roomTemp,roomRange);
  }
}

catch(NumberFormatException e)
{
%>

  <br>Error, all inputs must be integers.
  <br><a link="manual_control.jsp">Return to manual control page</a>

<%
}

%>


<meta http-equiv=REFRESH content=0;url=manual_control.jsp>

</body>
</html>